﻿using UnityEngine;
using System.Collections;

public class ArmorySellMoney : MonoBehaviour {

    enum MouseANKER { LEFT_TOP, LEFT_BOT, END};

    int m_anker;

	// Use this for initialization
	void Start () {
        transform.rotation = Quaternion.Euler(Vector3.zero);

        for (int i = 0; i < transform.childCount; ++i)
        {
            if (transform.GetChild(i).GetComponent<UISprite>())
                transform.GetChild(i).GetComponent<UISprite>().depth = GetComponent<UISprite>().depth + 1;
            else if (transform.GetChild(i).GetComponent<UILabel>())
                transform.GetChild(i).GetComponent<UILabel>().depth = GetComponent<UISprite>().depth + 1;
        }
	}

    // Update is called once per frame
    void Update()
    {
        switch (m_anker)
        {
            case (int)MouseANKER.LEFT_TOP:
                transform.position = UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition) + new Vector3(transform.localScale.x, -transform.localScale.y);
                break;
            case (int)MouseANKER.LEFT_BOT:
                transform.position = UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition) + new Vector3(transform.localScale.x, transform.localScale.y);
                break;
        }
	}

    public void BoxSetting(int anker, GameObject parentObj, Vector3 localscaleVec, string Label0 = "", string Label1 = "", string Label2 = "")
    {
        GetComponent<UISprite>().depth = parentObj.GetComponent<UISprite>().depth + 1;
        m_anker = anker;
        transform.localScale = localscaleVec;
        transform.GetChild(0).GetComponent<UILabel>().text = Label0;
        transform.GetChild(1).GetComponent<UILabel>().text = Label1;
        transform.GetChild(2).GetComponent<UILabel>().text = Label2;
    }
}
